from datetime import datetime
from sqlmodel import Field, SQLModel, Index
from typing import Optional

class XmArchive(SQLModel, table=True):
    """用户藏品表"""
    __tablename__ = "t_xm_archive"

    # 索引定义
    __table_args__ = (
        Index("idx_archiveId", "archiveId", unique=True, info="用户藏品ID唯一索引"),
    )

    id: int = Field(default=None, primary_key=True, description="主键ID")
    archiveId: int = Field(default=0, index=True, description="用户藏品ID")
    archiveName: str = Field(default="", max_length=128, description="用户藏品名称")
    archiveImg: str = Field(default="", max_length=255, description="用户藏品图片URL")
    platformId: int = Field(default=0, description="藏品发行平台ID")
    status: int = Field(default=0, description="状态：0-有效，1-无效")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
    updatedAt: datetime = Field(default_factory=datetime.now, description="更新时间")